<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${Title}</title>
<link rel="shortcut icon" href="${res}favicon.ico" type="image/x-icon" />
 <!--Basic Styles-->
<link href="${ctx }framework/css/font.css" rel="stylesheet" />
<link href="${ctx }framework/miniui/themes/material/miniui.css" rel="stylesheet" />
<link href="${ctx }framework/css/app.min.1.css" rel="stylesheet" type="text/css" />
<link href="${ctx }framework/css/app.min.2.css" rel="stylesheet" type="text/css" />
<script src="${ctx }framework/main.js" type="text/javascript"></script>
<style type="text/css">
    html, body{
        margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    }    
    </style>
</head>
<body class="body-detail">
	<script>
		Page.onLoad(function(){
			mini.get('dg1').load();	
		}); 
		function doSearch(){
			var dc = {
					Title:$V('Title'),
					StartTime:mini.get("StartTime").getFormValue(),
					EndTime:mini.get("EndTime").getFormValue(),
				}
				mini.get('dg1').load(dc) ;
			}
		//删除项目
		function removeRow() {
			var arr = mini.get("dg1").getSelectedValue();
			if (!arr || arr.length == 0) {
				top.mini.showTips({
					content : '请先选择要删除的记录！',
					state : 'info'
				});
				return;
			}
			
			top.mini.confirm("确定要删除么", function(action) {
				if (action == "ok") {
					var dc = {
						Id : arr.join()
					};
					Server.sendRequest("NewAccountNumber.deletePublicityId", dc, function(response) {
						if (response.Status == 1) {
							top.mini.showTips({
								content : response.Message,
								state : 'success'
							});
							mini.get('dg1').clearSelect();
							mini.get('dg1').reload();
						} else {
							top.mini.warn(response.Message);
						}
					});
				}
			});
		}
		function action(e) {
			var record = e.record
			e.cellStyle = "text-align:left";
			
	        return '<a href="javascript:viewUser(\'' + record.Id + '\')">查看</a>&nbsp;&nbsp;&nbsp;<a href="javascript:AuditPublicity(\''+ record.Id +'\')">通过审核</a>';
		}
		//查看公示
		function viewUser(member, company) {
		 	mini.open({
				width: 900,
				height : 800,
				title : "查看公示信息",
				url : "${ctx}eao/setting/viewPublicity.jhtml?Id=" + member,
				onLoad : function(){}
			});
		}

		//审核公示
		function AuditPublicity(id) {
			if (!id) {
				top.mini.showTips({
					content : '请先选择要删除的记录！',
					state : 'info'
				});
				return;
			}
			
			top.mini.confirm("确定要通过审核吗", function(action) {
				if (action == "ok") {
					var dc = {
						Id : id,
						State : 2
					};
					Server.sendRequest("NewAccountNumber.AuditPublicity", dc, function(response) {
						if (response.Status == 1) {
							top.mini.showTips({
								content : response.Message,
								state : 'success'
							});
							mini.get('dg1').clearSelect();
							mini.get('dg1').reload();
						} else {
							top.mini.warn(response.Message);
						}
					});
				}
			});
		}

		Server.sendRequest("EaoGrid.findBy", {},
				function(response) {
					if (response.Status == 1) {
						$("#TypeId").val(response.publicityAudit.Id);
						if(response.publicityAudit.IsAudit==0){
							$("#PublicityText").text("已关闭审核");
						}else{
							$("#PublicityText").text("已启用审核");
						}
					} else {
						top.mini.warn(response.Message);
					}
				});
		function enablePublicity(){
			var Id = $("#TypeId").val();
			Server.sendRequest("EaoGrid.saveOrUpdateType", {Id:Id,IsAudit:1},
			function(response) {
				if (response._STATUS == 1) {
					$("#PublicityText").text("已启用审核");
				} else {
					top.mini.warn(response.Message);
				}
			});
		}
		function disablePublicity(){
			var Id = $("#TypeId").val();
			Server.sendRequest("EaoGrid.saveOrUpdateType", {Id:Id,IsAudit:0},
			function(response) {
				if (response._STATUS == 1) {
					$("#PublicityText").text("已关闭审核");
				} else {
					top.mini.warn(response.Message);
				}
			});
		}
		function RealNameAction(e){
		    var RealName = "";
		    var Tel = "";
		    if(e.record.RealName){
			   RealName = e.record.RealName
			}
			if(e.record.Tel){
				Tel="("+e.record.Tel+")";
			}
			return RealName+Tel;
		}
	</script>
	
	<div class="search-area">
		<div class="pull-left">
			<a class="mini-button" iconCls="icon-remove" onclick="removeRow()" plain="true">删除</a> 
			<span id="PublicityText"></span>
			<input id="TypeId" type="hidden"/>
  			<a class="mini-button" iconCls="icon-circle-active" onclick="enablePublicity();" plain="true">启用</a>
			<a class="mini-button" iconCls="icon-ban" onclick="disablePublicity();" plain="true">停用</a>
		</div>
		<div class="pull-right">
			<input class="mini-textbox" id="Title" type="text" width="275" emptyText="请输入一级机构账号、公示名称、发布人账号或名字" />
			<input id="StartTime" class="mini-datepicker" value="" allowInput="false"  emptyText="提交日期止起" format="yyyy-MM-dd"/>
			<input id="EndTime" class="mini-datepicker" value="" allowInput="false"  emptyText="提交日期止" format="yyyy-MM-dd"/>
			<button class="btn btn-default" id="Submitbutton" onClick="doSearch()"><i class="iconfont icon-search"></i></button>
		</div>
	</div>
	
	<div class="mini-fit" style="padding:0 10px 10px 10px;">
		<div id="dg1" class="mini-datagrid z-depth-1" style="width:100%;height:100%;" method="NewAccountNumber.findAuditPublicity" idField="Id" multiSelect="true">
		   <div property="columns">
				<div type="checkcolumn"></div>
				<div type="indexcolumn"></div>
				<div field="CompanyMobile" width="5%">一级机构账号</div>
				<div field="FullName" width="9%">一级机构名称</div>
				<div field="Title" width="12%">公示名称</div>
				<div field="Mobile" width="5%">操作人账号</div>
				<div renderer="RealNameAction" width="8%">操作人姓名(联系方式)</div>
				<div field="PublicityTime" dateFormat="yyyy-MM-dd HH:mm:ss" width="7%">提交时间</div>
				<div name="action" renderer="action"  width="8%">操作</div>
			</div>
		</div>
	</div>
</body>
</html>